﻿@page "/JsInterop/HistoryView"

<MaanfeeDashboardPage>
    <MaanfeeDashboardPageHeader PageTitle="Web History API" Title="Web History API  - Maanfee Dashboard" SubTitle="The Web History API provides easy methods to access the windows.history object." />

    <DashboardPageContent>
        <DashboardPageSection Title="Examples">
            <MudGrid>
                <MudItem md="12">
                    <MudSimpleTable Dense="@true" Hover="@true" Bordered="@true" Striped="@true" Style="overflow-x: auto;">
                        <thead>
                            <tr>
                                <th>Method</th>
                                <th>Example</th>
                                <th>Selects</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @*Length*@
                            <tr>
                                <td style="color: #8323d8;">LengthAsync()</td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Success">
                                        await History.LengthAsync()
                                    </MudText>
                                </td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Info">
                                        Returns the number of URLs in the history list
                                    </MudText>
                                </td>
                                <td>
                                    <MudButton Disabled StartIcon="@Icons.Material.Filled.PlayArrow" Variant="Variant.Filled" Size="Size.Small" Color="Color.Success">Try</MudButton>
                                </td>
                            </tr>
                             @*Back*@
                            <tr>
                                 <td style="color: #8323d8;">BackAsync()</td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Success">
                                         await History.BackAsync()
                                    </MudText>
                                </td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Info">
                                         Loads the previous URL in the history list
                                    </MudText>
                                </td>
                                <td>
                                     <MudButton Disabled StartIcon="@Icons.Material.Filled.PlayArrow" Variant="Variant.Filled" Size="Size.Small" Color="Color.Success">Try</MudButton>
                                </td>
                            </tr>
                             @*Forward*@
                            <tr>
                                 <td style="color: #8323d8;">ForwardAsync()</td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Success">
                                         await History.ForwardAsync()
                                    </MudText>
                                </td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Info">
                                         Loads the next URL in the history list
                                     </MudText>
                                </td>
                                <td>
                                     <MudButton Disabled StartIcon="@Icons.Material.Filled.PlayArrow" Variant="Variant.Filled" Size="Size.Small" Color="Color.Success">Try</MudButton>
                                </td>
                            </tr>
                             @*Go*@
                            <tr>
                                 <td style="color: #8323d8;">GoAsync()</td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Success">
                                         await History.GoAsync()
                                    </MudText>
                                </td>
                                <td>
                                    <MudText Typo="Typo.caption" Color="Color.Info">
                                         Loads a specific URL from the history list
                                     </MudText>
                                </td>
                                <td>
                                     <MudButton Disabled StartIcon="@Icons.Material.Filled.PlayArrow" Variant="Variant.Filled" Size="Size.Small" Color="Color.Success">Try</MudButton>
                                </td>
                            </tr>
                        </tbody>
                    </MudSimpleTable>
                </MudItem>
            </MudGrid>
        </DashboardPageSection>
    </DashboardPageContent>
</MaanfeeDashboardPage>

 @code {
    protected override async Task OnInitializedAsync()
    {
        try
        {
            await History.ForwardAsync();
        }
        catch (Exception ex)
        {
            Snackbar.Add($"{DashboardResource.StringError} : {ex.ToString()}", Severity.Error);
        }
    }

}
